import com from '../js/common'
import axios from '../js/myAxios'

const axiosFunc = (url = '', data = {}, type = 'get') => {
  return new Promise((resolve, reject) => {
    if (type === 'get') {
      axios.get(url, data).then(resolve).catch(reject)
    } else {
      axios.post(url, data).then(resolve).catch(reject)
    }
  })
}
/**
 * 登录
 */

export const login = data => axiosFunc(`${com.basePath}/usercenter-web/user/login`, data, 'post')

/**
 * 登出
 */

export const logout = data => axiosFunc(`${com.basePath}/usercenter-web/user/logout`, data, 'post')

/**
 * 获取电梯类型数据
 */
export const getEleType = data => axiosFunc(`${com.basePath}/elevator-web/type/selects`, data)

/**
 * 获取电梯列表
 */

export const getEleList = data => axiosFunc(`${com.basePath}/elevator-web/infomain/selectElevator`, data, 'post')

/**
 * 获取电梯详情
 */

export const getEleDetail = data => axiosFunc(`${com.basePath}/elevator-web/infomain/select-all-details`, data, 'post')

/**
 * 获取电梯详情下历史
 */

export const getEleDetailHistory = data => axiosFunc(`${com.basePath}/elevator-web/elevatorLogs/page`, data, 'post')

/**
 * 添加电梯
 */

export const eleAdd = data => axiosFunc(`${com.basePath}/elevator-web/infomain/insert`, data, 'post')

/**
 * 修改电梯
 */

export const eleUpdate = data => axiosFunc(`${com.basePath}/elevator-web/infomain/update-selective`, data, 'post')

/**
 * 获取机构列表
 */

export const getOrganList = data => axiosFunc(`${com.basePath}/usercenter-web/department/page`, data, 'post')

/**
 * 获取机构类型列表
 */

export const getOrganTypeList = data => axiosFunc(`${com.basePath}/usercenter-web/departmentType/list`, data)

/**
 * 获取机构不同类型权限
 */

export const getOrganTypeRbac = data => axiosFunc(`${com.basePath}/usercenter-web/departmentType/auth/list`, data, 'post')

/**
 * 获取机构详情
 */

export const getOrganDetail = data => axiosFunc(`${com.basePath}/usercenter-web/department/detail`, data, 'post')

/**
 * 模糊查询机构,(包括物业单位,维保单位)
 */

export const queryOrgan = data => axiosFunc(`${com.basePath}/usercenter-web/department/queryList`, data, 'post')

/**
 * 添加机构
 */

export const organAdd = data => axiosFunc(`${com.basePath}/usercenter-web/department/add`, data, 'post')

/**
 * 修改机构
 */

export const organUpdate = data => axiosFunc(`${com.basePath}/usercenter-web/department/update`, data, 'post')

/**
 * 激活机构
 */

export const organActive = data => axiosFunc(`${com.basePath}/usercenter-web/department/activate`, data, 'post')

/**
 * 获取对应机构权限
 */

export const getOrganPower = data => axiosFunc(`${com.basePath}/usercenter-web/department/permissions/list`, data, 'post')
/**
 * 修改权限时获取对应机构权限
 */

export const getEditOrganPower = data => axiosFunc(`${com.basePath}/usercenter-web/department/permissions/changeList`, data, 'post')

/**
 * 修改对应机构权限
 */

export const updateOrganPower = data => axiosFunc(`${com.basePath}/usercenter-web/department/authorize`, data, 'post')
/**
 * 修改机构类型权限
 */

export const updateOrganRbac = data => axiosFunc(`${com.basePath}/usercenter-web/departmentType/auth/update`, data, 'post')

/**
 * 获取权限列表
 */

export const rbacPage = data => axiosFunc(`${com.basePath}/usercenter-web/permission/page`, data, 'post')

/**
 * 修改权限信息
 */

export const rbacUpdate = data => axiosFunc(`${com.basePath}/usercenter-web/permission/update`, data, 'post')

/**
 * 修改权限信息
 */

export const rbacAdd = data => axiosFunc(`${com.basePath}/usercenter-web/permission/add`, data, 'post')

/* 用户管理模块 */

/**
 * 查询用户管理
 */

export const userPage = data => axiosFunc(`${com.basePath}/usercenter-web/user/page`, data, 'post')

/**
 * 获取对应用户详细信息
 */

export const getUserDetail = data => axiosFunc(`${com.basePath}/usercenter-web/user/query`, data, 'post')

/**
 * 获取用户权限
 */

export const getUserRbac = data => axiosFunc(`${com.basePath}/usercenter-web/user/permissions`, data, 'post')

/**
 * 获取登录用户权限树
 */

export const getLoginUserRbac = data => axiosFunc(`${com.basePath}/usercenter-web/user/permission/list`, data, 'post')

/**
 * 获取意见反馈列表
 */

export const getFeedbackList = data => axiosFunc(`${com.basePath}/tend/feedback/page`, data, 'post')

/**
 * 删除单条意见反馈
 */

export const delFeedback = data => axiosFunc(`${com.basePath}/usercenter-web/user/permission/list`, data, 'post')

/**
 * 更新用户权限树
 */

export const updateUserRbac = data => axiosFunc(`${com.basePath}/usercenter-web/user/permission/update`, data, 'post')

/* 区域管理模块 */

/**
 * 获取区域列表
 */

export const getAreaPage = data => axiosFunc(`${com.basePath}/usercenter-web/area/page`, data, 'post')

/**
 * 添加区域
 */
export const addArea = data => axiosFunc(`${com.basePath}/usercenter-web/area/addBatch`, data, 'post')

/**
 * 更新区域信息
 */
export const updateAreaMsg = data => axiosFunc(`${com.basePath}/usercenter-web/area/update`, data, 'post')

// 豆

/**
 * 修改用户密码
 */

export const editUserPwd = data => axiosFunc(`${com.basePath}/usercenter-web/user/password`, data, 'post')

/**
 * 获取未读消息数
 */

export const getUnreadMsg = (data = {}) => axiosFunc(`${com.basePath}/notice/pushMessageInfo/selectNoReadMessage`, data, 'post')

/**
 * 获取消息通知列表
 */

export const getMsgDialogData = data => axiosFunc(`${com.basePath}/notice/pushMessageInfo/selecetPushMessageInfo`, data, 'post')

/**
 * 查看消息
 */

export const readOneMsg = data => axiosFunc(`${com.basePath}/notice/pushMessageInfo/selectMessageInfo`, data, 'post')

/**
 * 将全部消息标记为已读
 */

export const readAllMsg = data => axiosFunc(`${com.basePath}/notice/pushMessageInfo/updateAllReadState_toRead`, data, 'post')

/**
 * 获取巡检列表
 */

export const getExamineRecord = data => axiosFunc(`${com.basePath}/visit-web/new-patrol/platform-find-patrol`, data, 'post')

/**
 * 发布巡检任务
 */

export const addExaminePlain = data => axiosFunc(`${com.basePath}/visit-web/new-patrol/create-publish-patrol`, data, 'post')

/**
 * 获取巡检详情
 */
export const getExamineItemDetail = data => axiosFunc(`${com.basePath}/visit-web/new-patrol/detail`, data, 'post')

/**
 * 获取巡检人员数据
 */

export const getExamineUser = data => axiosFunc(`${com.basePath}/usercenter-web/user/targetUsers`, data, 'post')

/**
 * 获取巡检类型数据
 */

export const getExamineType = data => axiosFunc(`${com.basePath}/visit-web/patrol-type/patrol-types`, data, 'post')

/**
 * 获取巡检内容列表
 */

export const getExamineItems = data => axiosFunc(`${com.basePath}/visit-web/patrol-type/types`, data, 'post')

/**
 * 巡检内容项添加
 */

export const examineItemAdd = data => axiosFunc(`${com.basePath}/visit-web/patrol-type/add`, data, 'post')

/**
 * 巡检内容项編輯
 */

export const examineItemEdit = data => axiosFunc(`${com.basePath}/visit-web/patrol-type/update`, data, 'post')

/**
 * 巡检内容项删除
 */

export const examineItemDel = data => axiosFunc(`${com.basePath}/visit-web/patrol-type/deletes`, data, 'post')

/**
 * 修改巡检内容项是否禁用状态
 */

export const examineItemUpdate = data => axiosFunc(`${com.basePath}/visit-web/patrol-type/update`, data, 'post')

/**
 * 获取巡检类型数据
 */

export const getExamineItemType = data => axiosFunc(`${com.basePath}/visit-web/patrol-type/select`, data, 'post')

/**
 * 获取维保列表
 */

export const getMaintainRecord = data => axiosFunc(`${com.basePath}/tend/maintain/plan/page`, data, 'post')

/**
 * 获取维保项目列表
 */

export const getMaintainProject = data => axiosFunc(`${com.basePath}/elevator-web/maintainItem/selectItems`, data, 'post')

/**
 * 获取维保详情
 */

export const getMaintainQuery = data => axiosFunc(`${com.basePath}/tend/maintain/plan/detail`, data, 'post')

/**
 * 获取维保类型数据
 */

export const getMaintainType = data => axiosFunc(`${com.basePath}/elevator-web/maintainType/selects`, data, 'post')

/**
 * 获取维保项详情
 */

export const getMaintainProjectDetail = data => axiosFunc(`${com.basePath}/elevator-web/maintainItem/select`, data, 'post')

/**
 * 维保项添加
 */

export const maintainItemAdd = data => axiosFunc(`${com.basePath}/elevator-web/maintainItem/insert`, data, 'post')

/**
 * 维保项編輯
 */

export const maintainItemEdit = data => axiosFunc(`${com.basePath}/elevator-web/maintainItem/update-selective`, data, 'post')

/**
 * 维保项删除
 */

export const maintainItemDel = data => axiosFunc(`${com.basePath}/elevator-web/maintainItem/deletes`, data, 'post')

/**
 * 获取维保计划生成任务列表
 */

export const getMaintainTaskList = data => axiosFunc(`${com.basePath}/tend/maintain/task/page`, data, 'post')

/**
 * 维保计划生成任务审核操作
 */

export const maintainTaskCheck = data => axiosFunc(`${com.basePath}/tend/maintain/task/audit`, data, 'post')

/**
 * 生成维保计划
 */

export const maintainTaskAdd = data => axiosFunc(`${com.basePath}/tend/maintain/task/add`, data, 'post')

/**
 * 选择计划维保电梯列表
 */

export const getTaskEle = data => axiosFunc(`${com.basePath}/tend/info/page`, data, 'post')

/**
 *  通过维保类型查维保项
 */

export const maintainItemByType = data => axiosFunc(`${com.basePath}/elevator-web/maintainItem/selectByType`, data, 'post')

/**
 * 編輯维保计划
 */

export const maintainTaskEdit = data => axiosFunc(`${com.basePath}/tend/maintain/task/item/update`, data, 'post')
/**
 * 获取全部维保项数据
 */

export const getMaintainItemAll = data => axiosFunc(`${com.basePath}/tend/maintain/item/all`, data, 'get')

/**
 * 获取维保计划生成任务详情
 */

export const maintainTaskDetail = data => axiosFunc(`${com.basePath}/tend/maintain/task/detail`, data, 'post')

/**
 * 按区域code码回显地域
 */

export const getAreaTextByCode = data => axiosFunc(`${com.basePath}/usercenter-web/area/get`, data, 'post')

/**
 * 获取公告列表
 */

export const getNoticeList = data => axiosFunc(`${com.basePath}/news-web/news/lookall`, data, 'post')

/**
 * 公告发布
 */

export const noticePush = data => axiosFunc(`${com.basePath}/news-web/news/publish`, data, 'post')

/**
 * 公告编辑
 */

export const noticeEdit = data => axiosFunc(`${com.basePath}/news-web/news/edit`, data, 'post')

/**
 * 公告删除
 */

export const noticeDel = data => axiosFunc(`${com.basePath}/news-web/news/delete`, data, 'post')

/**
 * 获取公告详情
 */

export const noticeDetail = data => axiosFunc(`${com.basePath}/news-web/news/look-detail`, data, 'post')

// 故障管理
/**
 * 获取故障列表
 */

export const getFaultList = data => axiosFunc(`${com.basePath}/tend/trouble/page`, data, 'post')

/**
 * 获取故障详情
 */

export const getFaultDetail = data => axiosFunc(`${com.basePath}/tend/trouble/detail`, data, 'post')

/**
 * 获取维修列表
 */

export const getServiceList = data => axiosFunc(`${com.basePath}/tend/repair/page`, data, 'post')

/**
 * 获取维修详情
 */

export const getServiceDetail = data => axiosFunc(`${com.basePath}/tend/repair/detail`, data, 'post')

/**
 * 首页
 */

export const iGetMapData = data => axiosFunc(`${com.basePath}/elevator-web/elevatorLogs/index`, data, 'post')

/**
 * 首页-搜索下拉
 */
export const iGetSearchList = data => axiosFunc(`${com.basePath}/elevator-web/elevatorLogs/indexQueryList`, data, 'post')

/**
 * 首页-故障统计
 */
export const iGetFaultList = data => axiosFunc(`${com.basePath}/elevator-web/elevatorLogs/indexTroubleStatistics`, data, 'post')
